package com.leetcode.partition21;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/1/20 17:29
 */
public class LC2029石子游戏IX {

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] s = reader.readLine().split("\\s+");
        int[] nums = new int[s.length];
        for (int i = 0; i < s.length; i++) nums[i] = Integer.parseInt(s[i]);
        writer.write(stoneGameIX(nums) + "\n");
        writer.flush();
    }

    public static boolean stoneGameIX(int[] stones) {
        int[] cnt = new int[3];
        for (int stone : stones) cnt[stone % 3]++;
        if (cnt[0] % 2 == 0) return !(cnt[1] == 0 || cnt[2] == 0);
        return !(Math.abs(cnt[1] - cnt[2]) <= 2);
    }
}
